<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>欢迎查看你的队伍</title>
  <script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery"></script>
  <script src="__PUBLIC__/script/common.js" common-data-1="{:U('Mix/dest')}"></script>
  <!-- <script src="__PUBLIC__/script/jweixin-1.2.0.js"></script> -->
  <link rel="stylesheet" href="__PUBLIC__/script/jquery-weui/dist/lib/weui.min.css">
  <link rel="stylesheet" href="__PUBLIC__/script/jquery-weui/dist/css/jquery-weui.min.css">
  <link rel="stylesheet" href="__PUBLIC__/styles/base.css">
  <link rel="stylesheet" href="__PUBLIC__/styles/main.css">
  <style>
    /* 我的 */
    .wode.zuijin_card {
      background-image: url('__PUBLIC__/res/u245.png');
      background-repeat: no-repeat;
      background-position: 1rem 0;
    }
    /* 一级 */
    .yiji.zuijin_card {
      background-image: url('__PUBLIC__/res/u251.png');
      background-repeat: no-repeat;
      background-position: 1rem 0;
    }
    /* 二级 */
    .erji.zuijin_card {
      background-image: url('__PUBLIC__/res/u257.png');
      background-repeat: no-repeat;
      background-position: 1rem 0;
    }
  </style>
</head>
<body style="min-height:100vh;">
  <!-- 欢迎 -->
  <div class="hidden">
    <input type="hidden" name='模糊搜索链接' id='more_form_action' value="{:U('WebUser/new_pingu')}">
    <input type="hidden" name='精准搜索链接' id='less_form_action' value="{:U('WebUser/next_pingu_alt')}">
    <input type="hidden" name='获取所有大小类' id='ajax_biaoqina_dx' value="{:U('WebUser/ajax_biaoqina_dx')}">
    <!-- 不要管下边这一行的表单 -->
    <form autocomplete="off" action method="post" id ='hidden_form'></form>
  </div>
  <div class="container">
    <div class="header">{$Think.session.user.p_u_id|get_web_f_mesage}</div>
    <div class="nav">
      <span class="left active">我的团队</span>
      <span id='nav_my_pingu' class="center" inori-href="{:U('Mix/show_chat_list')}">我的评估</span>
      <if condition='$Think.session.user.web_type eq 1' ><span id='nav_my_tuandui' class="right" inori-href="{:U('Mix/show_chat_list_team')}">团队咨询</span></if>
    </div>
    <div class="message_box">

      <!-- 个人信息 -->
      <div class="me">
        <div class="renshu float_left">
          <div class="num">{$Think.session.user.web_id|teamcount}</div>
          <div class="ext">团队总人数</div>
        </div>
        <div class="logo float_left">
          <img id='my_logo' src="{$headimgurl}" alt="logo">
          <if condition='$Think.session.user.web_type eq 1' >
            <div class="me_type me_anjie">按</div>
           <else/>
             <div class="me_type me_anjie">业</div>
          </if>
        </div>
        <!-- <script>
          alert(`{$user.p_u_id}-{$user.p_u_id|get_pow_f}`)
        </script> -->
        <if condition="get_pow_f($user['p_u_id']) eq 1">
        <div class="need_more float_left" inori-href=`{:U('WebUser/qiye_signup')}` id='zhaobing_href'>
          <div class="func_img">
            <img src="__PUBLIC__/res/u227.png" alt="u227">
            <img class ='need_sec' src="__PUBLIC__/res/u229.png" alt="u229">
          </div>
          <div class="zhaobing"><a href="{:U('WebUser/qiye_signup')}" id='zhaobing_href_click'>继续招兵买马</a></div>
        </div>
        </if>
        <div class="float_clear"></div>
      </div>

      <div style='background-color:#EAEFF5;height: 1vh'></div>

      <!-- 最近 -->
      <div class="dongtai weui-flex">
        <div class="left float_left">
          <div class="title">近7日</div>
          <div class="border-box">
            <div class="wode zuijin_card">
              <span class="bold_font black_font">0个</span>
              <span>我的咨询</span>
            </div>
            <div class="yiji zuijin_card">
              <span class="bold_font black_font">0个</span>
              <span>一级咨询</span>
            </div>
            <div class="erji zuijin_card">
              <span class="bold_font black_font">0个</span>
              <span>二级咨询</span>
            </div>
          </div>
        </div>
        <div class="right float_left weui-flex__item">
          <div class="title">最新咨询</div>
          <volist name=":get_new_select($_SESSION['user']['web_id'])" id='vo'>
          <div class="card weui-flex" inori-data-addon='{$vo.count_zx}'>
            <div class="person_logo">
              <if condition="$vo['web_img']">
                     <img src="{$vo['web_img']}">
              <else /><img src="__PUBLIC__/res/me.png">
              </if>
            </div>
            <div class="person_main weui-flex__item">
              <div class='bold_font js-fliter_custom_name'>{$vo.web_name}</div>
              <div class="person_main_content" inori-data='{$vo.search_data}'>房产抵押贷200万</div>
            </div>
            <div class="present js-fliter_custom_present" inori-data='{$vo.data}'>70.00%</div>
          </div>
          </volist>
<!--           <div class="card weui-flex">
            <div class="person_logo">
              <img src="__PUBLIC__/res/me.png" alt="me">
            </div>
            <div class="person_main weui-flex__item">
              <div class='bold_font'>陈小春</div>
              <div class="person_main_content">房产抵押贷200万</div>
            </div>
            <div class="present">7%</div>
          </div>
          <div class="card weui-flex">
            <div class="person_logo">
              <img src="__PUBLIC__/res/me.png" alt="me">
            </div>
            <div class="person_main weui-flex__item">
              <div class='bold_font'>陈小春</div>
              <div class="person_main_content">房产抵押贷200万</div>
            </div>
            <div class="present">7%</div>
          </div> -->
        </div>
      </div>
      <div style='background-color:#EAEFF5;height: 1vh' id='js_half_below_this'></div>
      <!-- 新的贷款评估 -->
      <!-- <div class="iPhone5Only"></div> -->
      <div class="weui-flex" id='first_input' style="box-sizing:border-box;position:fixed;width:100%;background-color:#fff;bottom:0;left:0;right:0;">
        <div class="kehunianling weui-flex__item" title="客户年龄"><input type="num" name='kehu_old' id="kehu_old" class="long_buttom num_input" placeholder="请输入客户年龄"></div>
        <a href="javascript:void(0);" id='open_popup' data-target="#leibie_rukou_popup" class="mid_button inline_mid_button bg_main_color">开始咨询</a>
      </div>
      <div class="weui-flex" id='first_input_place' style="box-sizing:border-box;width:100%;background-color:#fff;left:0;right:0;height:60px;">
      </div>
      <!-- <div class="iPhone5Only"></div> -->

      <!-- 弹层 -->
      <div id="leibie_rukou_popup" class="weui-popup__container popup-bottom">
        <div class="weui-popup__overlay"></div>
        <div class="weui-popup__modal">
          <div class="toolbar">
            <div class="toolbar-inner">
              <a href="javascript:;" class="picker-button close-popup">关闭</a>
              <h1 class="title">选择咨询方式</h1>
            </div>
          </div>
          <div class="modal-content">
            <div class="weui-flex">
              <a href="javascript:void(0);" onclick="postThis(this, 'more')" class="weui-flex__item border_right">
                <div class="weui-grid__icon">
                  <img src="__PUBLIC__/res/u309.png" alt="u309">
                </div>
                <div class="weui-grid__label" style="width: calc(50vw - 15px);margin: 0 auto;">
                  模糊查询
                  <div class="desc" style='word-break:break-all;white-space:normal;'>客户情况不详，进行大概匹配</div>
                </div>
              </a>
              <a href="javascript:void(0)" onclick="postThis(this, 'less')" class="weui-flex__item">
                <div class="weui-grid__icon">
                  <img src="__PUBLIC__/res/u311.png" alt="u311">
                </div>
                <div class="weui-grid__label" style="width: calc(50vw - 15px);margin: 0 auto;">
                  精准查询
                  <div class="desc" style='word-break:break-all;white-space:normal;'>已经知道客户要具体做什么产品</div>
                </div>
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script src="__PUBLIC__/script/jquery-weui/dist/js/jquery-weui.min.js"></script>
  <!-- <script>
    $(document).ready(() => {
      wx.config({
        debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: 'wxc656de4aa072e4db', // 必填，企业号的唯一标识，此处填写企业号corpid
        timestamp: , // 必填，生成签名的时间戳
        nonceStr: '', // 必填，生成签名的随机串
        signature: '',// 必填，签名，见附录1
        // 上传照片， qrcode，关闭窗口
        jsApiList: ['chooseImage','previewImage','uploadImage','scanQRCode','closeWindow'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
      });
      wx.ready(function(){
        // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
        console.log('验证成功')
      });
      wx.error(function(res){
        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
        console.log('验证失败')
      });
    })
  </script> -->
  <script>
    function postThis (_this, type) {
      // 整个流程的
      sessionStorage.clear()
      if (type === 'less') {
        // $.toptip('暂未开放！敬请等待')
        // throw new Error('精确搜索')
        sessionStorage.setItem('less_pinggu', 'true')
      } else {
        sessionStorage.setItem('less_pinggu', '0')
      }
      let url = $(`#more_form_action`).val()
      sessionStorage.setItem('kehu_old', String($(`#kehu_old`).val()))
      sessionStorage.setItem('rawFormData', JSON.stringify($('#hidden_form').serializeArray()))
      // 该页面的,最后的序号表示页面顺序
      sessionStorage.setItem('rawFormData_1', JSON.stringify($('#hidden_form').serializeArray()))
      // 增加提示
      $.toptip('即将提交客户年龄', 'success')
      $.closePopup()
      setTimeout(function(){
        // 改为提交前修改其form属性，防止意外提交
        $('#kehu_old').attr('form', 'hidden_form' )
        $('#hidden_form').attr('action', url).submit()
      }, 0)
    }
  </script>
  <script>
    $(document).ready(() => {
      let value = sessionStorage.getItem('rawFormData_1') || ''
      if (value !== undefined && value !== null && value !== '[]') {
        try {
          let formData = JSON.parse(value)
          for(let item of formData) {
            if (item.name === 'kehu_old') {
              $(`#kehu_old`).val(item.value)
              console.log('重填已执行')
              sessionStorage.setItem('kehu_old', '')
            }
          }
        } catch (err) {
          console.log(err)
          console.log(`回填停止`)
          sessionStorage.setItem('kehu_old', '')
        }
      }
    })
  </script>
  <!-- 弹层逻辑，侦测是否已经填写 -->
  <script>
    $(document).ready(() => {
      $('#open_popup').on('click', () => {
        if ( $('#kehu_old').val() === '' || ~~Number($('#kehu_old').val()) < 18) {
          $.toptip("请正确填写成年用户年龄", "error")
          // $.toptip(`${$('.container').height()}`, "error")
        } else {
          $('#leibie_rukou_popup').popup()
        }
      })
    })
  </script>
  <!-- 跳转 -->
  <script>
    $(document).ready(() => {
      $('#nav_my_pingu').on('click', (evt) => {
        sessionStorage.setItem('isTeam', 'false')
        location.href = `${$(evt.target).attr('inori-href')}?front_end_not_submit=${Math.random()}`
      })
      $('#nav_my_tuandui').on('click', (evt) => {
        sessionStorage.setItem('isTeam', 'true')
        location.href = `${$(evt.target).attr('inori-href')}?front_end_not_submit=${Math.random()}`
      })
    })
  </script>
  <!-- 一些针对iphone的处理 -->
  <script>

    $(document).ready(() => {
      const offsetHeight = document.body.scrollHeight - $(`#js_half_below_this`)[0].offsetTop - $(`#js_half_below_this`)[0].offsetHeight
      const marginHeight = offsetHeight / 2 - $('.kehunianling').height() / 2
      if (marginHeight > 0 && marginHeight <= 31) {
        $('.kehunianling').closest('.weui-flex').css('padding-top', `${marginHeight}px`)
        $('.kehunianling').closest('.weui-flex').css('padding-bottom', `${marginHeight}px`)
      } else if (marginHeight > 0 && marginHeight > 31) {
        $.each($('.dongtai .zuijin_card'), (index, item) => {
          $(item).css('margin', '2rem 0')
        })
        $.each($('.dongtai .right .card'), (index, item) => {
          $(item).css('margin', '2rem 1rem')
        })
        // 做一次放宽后再调整
        const offsetHeight = document.body.scrollHeight - $(`#js_half_below_this`)[0].offsetTop - $(`#js_half_below_this`)[0].offsetHeight
        const marginHeight = offsetHeight / 2 - $('.kehunianling').height() / 2
        $('.kehunianling').closest('.weui-flex').css('padding-top', `${marginHeight > 0 ? marginHeight : 10}px`)
        $('.kehunianling').closest('.weui-flex').css('padding-bottom', `${marginHeight > 0 ? marginHeight : 10}px`)
      }
      else {
        $('.kehunianling').closest('.weui-flex').css('margin-top', `10px`)
        $('.kehunianling').closest('.weui-flex').css('margin-bottom', `10px`)
      }
      // $(`#first_input`).css('height', $('.kehunianling').closest('.weui-flex').css('height'))
      if(!window.inori_temp_var) window.inori_temp_var = {}
      window.inori_temp_var.max_height = $(window).height()
      $(window).on('resize', (evt) => {
      // 整体页面，防止被键盘遮挡
      const bodyHeight = $(window).height()
      const target = $(`#first_input`)

      if (window.inori_temp_var && window.inori_temp_var.max_height && bodyHeight < window.inori_temp_var.max_height) {
        window.scrollTo(0,0)
        $(`#first_input > *`).css('padding-top', '5px')
        $(`#first_input > *`).css('padding-bottom', '5px')
        target.css('bottom', '0px')
        console.log(bodyHeight)
        console.log(1)
      } else {
        $(`#first_input > *`).css('padding-top', '0')
        $(`#first_input > *`).css('padding-bottom', '0')
        // 不一定unset
        if($('#first_input').css('margin-bottom') > 0) {
          const value = $('#first_input').css('margin-bottom')
          target.css('bottom', value)
        } else {
          target.css('bottom', '0')
        }
        // if ($('#first_input input').val()) {
        //   setTimeout($(`#open_popup`).click(), 100)
        // }
      }
    })
    $(`#first_input input`).on('focus change keyup', (evt) => {
      const bodyHeight = $(window).height()
      const target = $(`#first_input`)
      if (window.inori_temp_var && window.inori_temp_var.max_height && bodyHeight < window.inori_temp_var.max_height) {
        console.log(bodyHeight)
        console.log(2)
        window.scrollTo(0,0)
        $(`#first_input > *`).css('padding-top', '5px')
        $(`#first_input > *`).css('padding-bottom', '5px')
        target.css('bottom', '0px')
      }
    })
    $(`#first_input input`).on('blur', (evt) => {
      const bodyHeight = $(window).height()
      const target = $(`#first_input`)
      if (window.inori_temp_var && window.inori_temp_var.max_height && bodyHeight < window.inori_temp_var.max_height) {
        console.log(bodyHeight)
        console.log(3)
        $(`#first_input > *`).css('padding-top', '0')
        $(`#first_input > *`).css('padding-bottom', '0')
        // 不一定unset
        if($('#first_input').css('margin-bottom') > 0) {
          const value = $('#first_input').css('margin-bottom')
          target.css('bottom', value)
        } else {
          target.css('bottom', '0')
        }
        // if ($('#first_input input').val()) {
        //   setTimeout($(`#open_popup`).click(), 100)
        // }
      }
    })
  })

    // $(`#first_input`).on('click', (evt) => {
    //   setTimeout(()=>{
    //     window.scrollTo( 0, 100000000000000000 )
    //   }, 100)
    //   setTimeout(()=>{
    //     window.scrollTo( 0, 100000000000000000 )
    //   }, 200)
    //   setTimeout(()=>{
    //     window.scrollTo( 0, 100000000000000000 )
    //   }, 300)
    //   setTimeout(()=>{
    //     window.scrollTo( 0, 100000000000000000 )
    //     $.toptip('23', 'success')
    //   }, 800)
    // })
  </script>
  <!-- 保存个人头像 -->
  <script>
    $(document).ready(() => {
      const imgURL = $('#my_logo').attr('src')
      if( imgURL !== undefined && imgURL !== '' ) {
        sessionStorage.setItem('my_logo', String(imgURL))
      } else {
        sessionStorage.setItem('my_logo', String('null'))
      }
    })
  </script>
  <!-- 跳转招兵 -->
  <script>
    $(document).ready(() => {
      $('#zhaobing_href').on('click', (evt) => {
        location.href = $('#zhaobing_href_click').attr('href')
      })
    })
  </script>
  <!-- 屏蔽0值或者空值 -->
  <script>
    $(document).ready(() => {
      // $('.zuijin_card .black_font').each((idex, item) => {
      //   if($(item).text() === '个' || $(item).text() === '0个' ) {
      //     $(item).text(`--个`)
      //   }
      // })
      // 循环处理空名字
      $(`.js-fliter_custom_name`).each((index, item) => {
        if ($(item).text() == '') {
          $(item).text('--')
        }
      })
      // 处理card信息
      $.each($('.right .card'), (index, item) => {
        if ($(item).attr('inori-data-addon') || $(item).attr('inori-data-addon') === '0') {
          // 拿到人数
          $(`.zuijin_card:eq(${index}) .black_font`).text(`${$(item).attr('inori-data-addon') === '0' ? '--人' : $(item).attr('inori-data-addon') + "人" }`)
        }
        if ($(item).find('.js-fliter_custom_present').attr('inori-data')) {
          // 获取额度佣金点数
          let ziliaoValue = $(item).find('.js-fliter_custom_present').attr('inori-data')
          try {
            ziliaoValue = JSON.parse(ziliaoValue)
            // 额度
            let edu = ziliaoValue.find(item => item.name === 'kehu_edu')
            if (edu) {
              edu = `${edu.value}万`
              // 修改额度
              $(item).find('.person_main_content').text(edu)
            }
            // 佣金
            let yongjin = ziliaoValue.find(item => item.name === 'kehu_plan_point')
            if (yongjin) {
              yongjin = `${yongjin.value}%`
              // js-fliter_custom_present
              // 修改佣金
              $(item).find('.js-fliter_custom_present').text(yongjin)
            }
          } catch (err) {
            debugger
            console.log(err)
            console.err('最新资询资料中客户资料渲染发生错误')
          }
        }
        // if ($(item).find('.person_main_content').attr('inori-data')) {
        //   let value = $(item).find('.person_main_content').attr('inori-data')
        //   try {
        //     value = JSON.parse(value)
        //     // 选一个小类id
        //     const xiaoleID = value[3][1].split(',')[0]
        //     let daleiName = ``
        //     let xiaoleiAll = ''
        //     $.ajax(`${$('#ajax_biaoqina_dx').val()}`, {
        //       method: 'get'
        //     }).fail((err) => {
        //       debugger
        //       console.log(err)
        //     }).done((res) => {
        //       debugger
        //       console.log(res)
        //       xiaoleiAll = res
        //       // 在全部小类中获取上边选定小类所在的组（大类）
        //       $.each(xiaoleiAll, (subIndex, subItem) => {
        //         if (daleiName !== '') return
        //         const ifHad = subItem.xb.findIndex(i => `${i.id}` === `${xiaoleID}`)
        //         if (ifHad > -1) {
        //           daleiName = subItem.name
        //         }
        //       })
        //       if (daleiName === '') daleiName = '房产抵押贷'

        //       // 修改大类
        //       const origin = $(item).find('.person_main_content').text()
        //       $(item).find('.person_main_content').text(`${daleiName}${origin}`)
        //     })
        //   } catch (err) {
        //     debugger
        //     console.log(err)
        //     console.err('最新资询资料中客户搜索资料渲染发生错误')
        //   }
        // }
      })
      // 循环处理长佣金
      $(`.js-fliter_custom_present`).each((index, item) => {
        if (item.scrollWidth !== item.clientWidth) {
          $(item).css('font-size', '12px')
        }
      })
      // 固定相关项目数值……简直深坑

      // $('html').css('height', $('html').css('height'))
      // $(document.body).css('min-height', $(document.body).css('min-height'))
      $(document.body).css('font-size', $(document.body).css('font-size'))
      // $(`.container`).css('height', $(`.container`).css('height'))
      $(`.me .need_more img:eq(0)`).css('top', $(`.me .need_more img:eq(0)`).css('top'))
      $(`.me .need_more img.need_sec`).css('top', $(`.me .need_more img.need_sec`).css('top'))

      // const meDivPaddingTop = $(`.me > div`).css('padding-top')
      // $(`.me > div`).each((index, item) => {
      //   $(item).css('padding-top', meDivPaddingTop)
      // })
      $(`.me .renshu`).css('padding-top', $(`.me .renshu`).css('padding-top'))
      // 防止页面后退
      // 页面载入时使用pushState插入一条历史记录
      history.pushState(null, null, "{:U('Wchat/main')}" + "?front_end_not_submit=" + Math.random());
      console.log('刷新');
      window.addEventListener('popstate', function(event) {
          console.log('回退');
          // 点击回退时再向历史记录插入一条，以便阻止下一次点击回退
          history.pushState(null, null, "{:U('Wchat/main')}" + "?front_end_not_submit=" + Math.random());
      });
    })
  </script>
</body>
</html>